package com.hczt.springcloud.servicehan.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * 把今天最好的表现当作明天最新的起点．．～
 * いま 最高の表現 として 明日最新の始発．．～
 * Today the best performance  as tomorrow newest starter!
 *
 * @author marvin.ma
 * @create 2017-10-23 14:19
 * @desc 外暴的接口测试Zipkin服务追踪
 **/
@RestController
public class ZipkinTestController {

    private static final Logger logger = LoggerFactory.getLogger(ZipkinTestController.class);


    @RequestMapping("/hi")
    public String home() {
        logger.info( "calling trace service-han");
        return "Hi, i'm service han!";
    }

    @RequestMapping("/miya")
    public String info() {
        logger.info("miya is being called on eureka-han ");
        return restTemplate.getForObject("http://localhost:8988/hi",String.class);
    }

    @Autowired
    private RestTemplate restTemplate;

    @Bean
    public RestTemplate getRestTemplate(){
        return new RestTemplate();
    }
}
